package top.bug.blog.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.bug.blog.annotation.RateLimit;
import top.bug.blog.common.Result;
import top.bug.blog.entity.dto.album.AlbumQueryRequest;
import top.bug.blog.entity.dto.common.SingleRequest;
import top.bug.blog.entity.po.Album;
import top.bug.blog.entity.po.AlbumPic;
import top.bug.blog.service.AlbumService;

import javax.annotation.Resource;
import java.util.List;

import static top.bug.blog.enums.RateLimitEnum.QUERY_LIMIT;

/**
 * @author <a href="https://github.com/jiusi66">九思.</a>
 * @email 10837907@qq.com
 * @from <a href="https://www.52bug.top">递归茶馆-www.52bug.top</a>
 * @description 后台-相册模块
 */
@RestController("FrontAlbumController")
@Api(tags = "相册管理模块")
@RequestMapping("/api/album")
public class AlbumController {
    @Resource
    private AlbumService albumService;

    @PostMapping("/getList")
    @ApiOperation("获取列表")
    @RateLimit(strategyEnum = QUERY_LIMIT)
    public Result<Page<Album>> getList(@RequestBody AlbumQueryRequest queryRequest) {
        return Result.success(albumService.getList(queryRequest));
    }

    @PostMapping("/getPicList")
    @ApiOperation("获取相册图片列表")
    @RateLimit(strategyEnum = QUERY_LIMIT)
    public Result<List<AlbumPic>> getPicList(@RequestBody SingleRequest singleRequest) {
        return Result.success(albumService.getPicList(singleRequest));
    }

}